package com.luke.springcloud.controller;

import com.luke.springcloud.entities.UserInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * @Descrtption FeignProviderController
 * @Author luke
 * @Date 2020/5/12
 **/
@Slf4j
@RequestMapping("/provider")
@RestController
public class FeignProviderController {

    @GetMapping("/echo/{id}")
    public UserInfo echo(@PathVariable("id") Long id) throws Exception{
        log.info("echo,id:{}",id);
        int i = 1 / 0;
        //休眠3秒
        TimeUnit.SECONDS.sleep(3);
        return new UserInfo(id,"luke",18,new Date());
    }

    @GetMapping("/query")
    public UserInfo queryUserInfo(UserInfo userInfo){
        log.info("queryUserInfo,userInfo:{}",userInfo);
        return new UserInfo(userInfo.getId(),"luke",18,new Date());
    }

}
